package day12;

import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;

public class Computer {
    private String brand;
    private int price;
    private String resolution;
    private String start;//电脑状态
    private String format;//是否格式化
    private String install;//是否安装了系统
    private String os;//电脑系统

    private String color;
    private double size;
    Disk[] disks = new Disk[5];
    Disk h = new Disk();

    int count = 0;


    public Computer() {

    }

    public Computer(String brand, int price, String resolution, String color) {
        this.brand = brand;
        this.price = price;
        this.resolution = resolution;
        this.color = color;

    }

    public Computer(String brand, int price, String resolution, String start, String format, String install, String color, double size, String os) {
        this.brand = brand;
        this.price = price;
        this.resolution = resolution;
        this.start = start;
        this.format = format;
        this.install = install;
        this.color = color;
        this.size = size;
        this.os = os;


    }

    public String getOs() {
        return os;
    }

    public void setOs(String os) {
        this.os = os;
    }

    public String getStart() {
        return start;
    }

    public void setStart(String start) {
        this.start = start;
    }

    public String getFormat() {
        return format;
    }

    public void setFormat(String format) {
        this.format = format;
    }

    public String getInstall() {
        return install;
    }

    public void setInstall(String install) {
        this.install = install;
    }

    public Disk[] getDisks() {
        return disks;
    }

    public void setDisks(Disk[] disks) {
        this.disks = disks;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public String getResolution() {
        return resolution;
    }

    public void setResolution(String resolution) {
        this.resolution = resolution;
    }


    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public double getSize() {
        return size;
    }

    public void setSize(double size) {
        this.size = size;
    }


    public void start() {
        this.setStart("已开机");
        System.out.println("启动成功");
    }

    public void close() {
        this.setStart("已关机");
        System.out.println("电脑关机");
    }

    //格式化
    public boolean format(Disk disk) {
        if (getStart().equals("未开机")) {
            return false;
        } else {

            getStart().equals("已开机");
        }
        if (count >= disks.length) {
            Disk[] disks1 = new Disk[disks.length + 10];
            for (int i = 0; i < count; i++) {
                disks1[i] = disks[i];
            }
            disks = disks1;
        }
        disks[count] = disk;
        count++;
        format.equals("已格式化");
        System.out.println("格式化成功");
        return true;
    }

    //安装操作系统
    public boolean setup(SoftWare a, String disk) {
        if (install.equals("未安装系统")) {
            if (a.getName().equals("win7") || a.getName().equals("win8") || a.getName().equals("win10")) {
                for (int i = 0; i < count; i++) {
                    if (disks[i].getType().equals(disk) && disks[i].getSize() > a.getSize()) {
                        h.install(a);
                        disks[i].setSize(disks[i].getSize() - a.getSize());
                        System.out.println("系统" + a.getName() + "安装成功");
                        return true;

                    }
                }
            }
            install.equals("已安装系统");
        }
        return false;
    }


    public boolean add(String p, SoftWare f) {
        if (install.equals("系统已安装") && start.equals("已开机") && format.equals("已格式化")) {
            for (int i = 0; i < count; i++) {
                if (disks[i].getType().equals(p) && disks[i].getSize() > f.getSize()) {
                    h.install(f);
                    disks[i].setSize(disks[i].getSize() - f.getSize());
                    System.out.println("软件" + f.getName() + "安装成功");
                    return true;
                }
            }
        }
        return false;
    }

    //安装下载软件
    public boolean mount(String p, DowSoftWare d) {
        if (install.equals("系统已安装") && start.equals("已开机") && format.equals("已格式化")) {
            for (int i = 0; i < count; i++) {
                if (disks[i].getType().equals(p) && disks[i].getSize() > d.getSize()) {
                    h.install(d);
                    disks[i].setSize(disks[i].getSize() - d.getSize());
                    System.out.println("下载软件" + d.getName() + "安装成功");
                    return true;
                }
            }
        }
        return false;
    }
    //查看下载
    public void showsoft(){
        for (int i = 0; i < count; i++) {
            disks[i].show2();
        }
    }

}
